package visualizer.client.widgets.controlPanel;

import com.google.gwt.user.client.ui.Widget;
import visualizer.client.event.ControlPanelEventHandler;
import visualizer.client.utils.AlgorithmType;

/**
 * User: DDovzhenko
 * Date: 30.12.13
 * Time: 15:17
 */
public class ControlPanelPresenter {
    private Display view;

    public ControlPanelPresenter(Display view) {
        this.view = view;
    }

    public Widget asWidget() {
        return view.asWidget();
    }

    public void onResize() {
        view.onResize();
    }

    public void setEventListener(ControlPanelEventHandler handler) {
        view.setEventListener(handler);
    }

    public void setMessage(String stepDescription) {
        view.setMessage(stepDescription);
    }

    public void setAlgorithmType(AlgorithmType selectedAlgorithmType) {
        view.setInputFieldVisible(selectedAlgorithmType.isInputFieldVisible());
        view.setBeginButtonText(selectedAlgorithmType.getBeginButtonText());
    }

    public int getAnimationSpeed() {
        return view.getAnimationSpeed();
    }

    public void setAnimation(boolean isAnimate) {
        view.setAnimation(isAnimate);
    }

    interface Display {
        Widget asWidget();
        void onResize();
        void setEventListener(ControlPanelEventHandler handler);
        void setMessage(String message);
        void setInputFieldVisible(boolean isVisible);
        void setBeginButtonText(String text);
        int getAnimationSpeed();
        void setAnimation(boolean isAnimate);
    }
}
